﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Payment.API.Infrastructure.EntityConfigurations;
using Payment.API.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Payment.API.Infrastructure
{
    public class PaymentContext :  DbContext
    {
        public PaymentContext(DbContextOptions<PaymentContext> options) : base(options)
        {
        }
        public DbSet<PaymentLog> PaymentLogs { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.ApplyConfiguration(new PaymentLogEntityTypeConfiguration());
        }
    }
    public class PaymentContextDesignFactory : IDesignTimeDbContextFactory<PaymentContext>
    {
        public PaymentContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<PaymentContext>()
                .UseSqlServer("Server=.;Initial Catalog=PaymentDb;Integrated Security=true");

            return new PaymentContext(optionsBuilder.Options);
        }
    }
}
